package com.servlet;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.Map;


import hyl.core.MyFun;
import hyl.core.conf.MyConst;
import hyl.core.db.MyDB;
/**
 * 存放扩展参数
 * @author 37798955@qq.com
 *
 */
public class M2 {
	public static int ROLE_管理员 = 1;
	public static int ROLE_用户 = 2;	
	public static int 密钥错误 = 200;
	public static int 手机重复 = 201;
	public static int 无效域名 = 500;
	public static int 无效token = 501;
	public static int 频繁token = 502;//有效期内不得频繁请求
	
	public static long 失效时间 = 300000;//5分钟

	public static String get上传路径() {
		 MyConst mcConst=MyConst.getInstance();
		 return mcConst.get("UPLOAD_URL");
	}
	/**
	 * 
	 * @用于判断权限
	 */
	public static String getRole(int 权限id) {
		List<Map<String, Object>> list = M.LRole;
		String 可用权限="";
		for (Map<String, Object> b : list) {
			int roleid = MyFun.obj2Int(b.get("id"));
			if((权限id&roleid)==roleid) {
				可用权限+=b.get("manage");
			}
		}
		return 可用权限;
	}
	
	// 会员权限
	public static List<Map<String, Object>> getRoles() {
		MyDB db = My.getDB1();
		String sql = "select id,manage from sys_rolemanage a";
		List<Map<String, Object>> list = db.queryList(sql, null);
		return list;
	}
	
	/**
	 * "yyyy-MM-dd HH:mm:ss SSS"
	 * */
	public static String get今天(String type) {
		SimpleDateFormat df = new SimpleDateFormat(type);//设置日期格式
		return df.format(new Date());
	}
	
}
